local ma__qiangshu = fk.CreateSkill {
  name = "ma__qiangshu",
}

Fk:loadTranslationTable{
  ["ma__qiangshu"] = "枪术",
  [":ma__qiangshu"] = "当你使用或打出【杀】/【闪】后，你可以获得一张【闪】/【杀】。",

  --["#ma__qiangshu_jink"] = "你可以对自己使用一张【闪】",
}

local spec = {
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(ma__qiangshu.name) and target == player then
      return data.card.trueName == "slash" or data.card.trueName == "jink"
    end
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askToSkillInvoke(player, { skill_name = ma__qiangshu.name }) then
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card
    if data.card.trueName == "slash" then
      card = "jink"
    else card = "slash"
    end
    local id = room:getCardsFromPileByRule(card, 1, "allPiles")
    if #id > 0 then
      room:obtainCard(player, id, false, fk.ReasonJustMove, player, ma__qiangshu.name)
    end
  end,
}

ma__qiangshu:addEffect(fk.CardUseFinished, spec)
ma__qiangshu:addEffect(fk.CardRespondFinished, spec)

--[[ma__qiangshu:addEffect("active", {
  anim_type = "offensive",
  prompt = "#ma__qiangshu_jink",
  card_num = 1,
  target_num = 0,
  can_use = Util.TrueFunc,
  target_filter = Util.FalseFunc,
  card_filter = function(self, player, to_select, selected)
    if #selected == 0 and Fk:getCardById(to_select).trueName == "jink" then
      local card = Fk:cloneCard("combo__jink")
      card:addSubcard(to_select)
      return not player:prohibitUse(card) and not player:isProhibited(player, card)
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:useVirtualCard("combo__jink", effect.cards, player, player, ma__qiangshu.name)
  end,
})]]

return ma__qiangshu
